package com.testplatfrom.project.controller;


import com.testplatfrom.common.core.domain.R;
import com.testplatfrom.common.core.web.domain.AjaxResult;
import com.testplatfrom.common.log.annotation.Log;
import com.testplatfrom.common.log.enums.BusinessType;
import com.testplatfrom.common.security.annotation.RequiresPermissions;
import com.testplatfrom.project.domain.TestplatfromProject;
import com.testplatfrom.project.domain.dto.project.TestplatfromProjectAdd;
import com.testplatfrom.project.domain.dto.project.TestplatfromProjectEdit;
import com.testplatfrom.project.domain.dto.project.TestplatfromProjectPage;
import com.testplatfrom.project.domain.dto.project.TestplatfromProjectPageVo;
import com.testplatfrom.project.service.TestplatfromProjectService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import static com.testplatfrom.common.core.web.domain.AjaxResult.success;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 杨森
 * @since 2023-06-26
 */
@RestController
@RequestMapping("/testplatfromProject")
public class TestplatfromProjectController {

    @Autowired
    private TestplatfromProjectService testplatfromProjectService;

    /**
     * 查询项目管理列表
     */
    @ApiOperation(value = "查询项目管理列表", notes = "查询项目管理列表")
    @RequiresPermissions("project:project:list")
    @GetMapping("/list")
    public R<TestplatfromProjectPageVo> list(TestplatfromProjectPage testplatfromProjectPage) {
        return R.ok(testplatfromProjectService.listTestplatfromProject(testplatfromProjectPage));
    }

    /**
     * 导出项目管理列表
     */
    @ApiOperation(value = "导出项目管理列表", notes = "导出项目管理列表")
    @RequiresPermissions("project:project:export")
    @Log(title = "项目管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TestplatfromProject testplatfromProject) {
    }

    /**
     * 获取项目管理详细信息
     */
    @ApiOperation(value = "获取项目管理详细信息", notes = "获取项目管理详细信息")
    @RequiresPermissions("project:project:query")
    @GetMapping(value = "/{testplatfromProjectId}")
    public AjaxResult getInfo(@PathVariable("testplatfromProjectId") String testplatfromProjectId) {
        return success(testplatfromProjectService.getDetailTestplatfromProject(testplatfromProjectId));
    }

    /**
     * 新增项目管理
     */
    @ApiOperation(value = "新增项目管理", notes = "新增项目管理")
    @RequiresPermissions("project:project:add")
    @Log(title = "项目管理", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Boolean> add(@Valid @RequestBody TestplatfromProjectAdd testplatfromProjectAdd) {
        return R.ok(testplatfromProjectService.addTestplatfromProject(testplatfromProjectAdd));
    }

    /**
     * 修改项目管理
     */
    @ApiOperation(value = "修改项目管理", notes = "修改项目管理")
    @RequiresPermissions("project:project:edit")
    @Log(title = "项目管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Boolean> edit(@Valid @RequestBody TestplatfromProjectEdit testplatfromProjectEdit) {
        return R.ok(testplatfromProjectService.updateTestplatfromProject(testplatfromProjectEdit));
    }

    /**
     * 删除项目管理
     *
     * @return
     */
    @ApiOperation(value = "删除项目管理", notes = "删除项目管理")
    @RequiresPermissions("project:project:remove")
    @Log(title = "项目管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{testplatfromProjectId}")
    public R<Boolean> remove(@PathVariable String testplatfromProjectId) {
        return R.ok(testplatfromProjectService.deleteTestplatfromProject(testplatfromProjectId));
    }


    /**
     * 项目查询
     *
     * @return
     */
    @ApiOperation(value = "项目查询", notes = "项目查询")
    @GetMapping("/selectList")
    public R selectTestPlatfromProject() {
        return R.ok(testplatfromProjectService.selectTestplatfromProject());
    }

}

